<?php

namespace App\Transformers;

use App\Models\FsUserRemark;
use League\Fractal\TransformerAbstract;

class FsUserRemarkTransformer extends TransformerAbstract
{

    protected $availableIncludes = ['user','fsUser'];

    public function __construct($model = '')
    {
        if(!empty($model)){
            $this->defaultIncludes = [$model];
        }
    }

    public function transform(FsUserRemark $fsUserRemark)
    {
        return [
            'id' => $fsUserRemark->id,
            'remark' => $fsUserRemark->remark,
            'user_id' => $fsUserRemark->user_id,
            'fs_user_id' => $fsUserRemark->fs_user_id,
            'created_at' => empty($fsUserRemark->created_at)?'':$fsUserRemark->created_at->toDateTimeString(),
            'updated_at' => empty($fsUserRemark->updated_at)?'':$fsUserRemark->updated_at->toDateTimeString(),
        ];
    }

    public function includeUser(FsUserRemark $fsUserRemark)
    {
        return $this->item($fsUserRemark->user, new UserTransformer());
    }

    public function includeFsUser(FsUserRemark $fsUserRemark)
    {
        return $this->item($fsUserRemark->fsUser, new FsUserTransformer());
    }

}